package com.android.kotlincoroutinemvvmdemo.view
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import com.android.kotlincoroutinemvvmdemo.R

/*
* QuickShareView
* */
class QuickShareView @JvmOverloads constructor(
    context: Context,
    attributeSet: AttributeSet? = null
) : BaseView(context, attributeSet) {

    private val mPaint0 by lazy {
        Paint().apply {
            isAntiAlias = true
            isDither = true
            strokeCap = Paint.Cap.ROUND
            strokeWidth = context.resources.getDimension(R.dimen.dp_2)
            color = context.resources.getColor(R.color.color_C6FF00)
            style = Paint.Style.STROKE
        }
    }

    private val mPaint1 by lazy {
        Paint().apply {
            isAntiAlias = true
            isDither = true
            color = context.resources.getColor(R.color.color_C6FF00)
            style = Paint.Style.FILL
        }
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        setBackgroundColor(context.resources.getColor(R.color.color_F3F3F3))
        canvas?.apply {
            val cx = mWidth.toFloat() / 2
            val cy = mHeight.toFloat() / 2

            drawArc(
                cx - cx / 16,
                cy - cy / 16,
                cx + cx / 16,
                cy + cy / 16,
                0F,
                360F,
                false,
                mPaint1
            )

            drawArc(
                cx - cx / 2,
                cy - cy / 2,
                cx + cx / 2,
                cy + cy / 2,
                135F,
                90F,
                false,
                mPaint0
            )

            drawArc(
                cx - cx / 4,
                cy - cy / 4,
                cx + cx / 4,
                cy + cy / 4,
                135F,
                90F,
                false,
                mPaint0
            )

            drawArc(
                cx - cx / 2,
                cy - cy / 2,
                cx + cx / 2,
                cy + cy / 2,
                315F,
                90F,
                false,
                mPaint0
            )

            drawArc(
                cx - cx / 4,
                cy - cy / 4,
                cx + cx / 4,
                cy + cy / 4,
                315F,
                90F,
                false,
                mPaint0
            )
        }
    }
}